package com.ele.client.activity.editor.widget;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

public class NavigationEvent extends GwtEvent<NavigationEvent.Handler> {

    public enum Direction {
        UP, DOWN
    }

    private Direction direction;
    private int fieldIndex;

    public NavigationEvent(Direction direction, int fieldIndex) {
        this.direction = direction;
        this.fieldIndex = fieldIndex;
    }

    public interface Handler extends EventHandler {
        void onClick(NavigationEvent event);
    }

    public static Type<Handler> TYPE = new Type<Handler>();

    @Override
    public Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onClick(this);
    }

    public Direction getDirection() {
        return direction;
    }

    public int getFieldIndex() {
        return fieldIndex;
    }

    public static Type<Handler> getType() {
        return TYPE;
    }
}
